<template>
  <div class="detailbottombar">
    <div class="right">
      <span v-for="(item, index) in titles">
        <i class="icon"></i>
        <p>{{ item }}</p>
      </span>
      <span class="center" @click="itemClick">
        <img src="~assets/img/tabbar/shopcart.svg" alt="" />
        <p>购物车</p>
        <div class="little" v-if="Length !== 0">{{ Length }}</div>
      </span>
    </div>
    <div class="left">
      <div class="shopcar" @click="addToCart">加入购物车</div>
      <div class="buy">购买</div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "DetailBottomBar",
  data() {
    return {
      titles: ["客服", "店铺", "收藏"],
    };
  },
  computed: {
    ...mapGetters({ Length: "cartLength", list: "cartList" }),
  },
  methods: {
    addToCart() {
      this.$emit("addCart");
    },
    itemClick() {
      this.$router.replace("/cart");
    },
  },
  components: {},
};
</script>

<style  scoped>
.detailbottombar {
  display: flex;
  height: 49px;
  background-color: white;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 13px;
  text-align: center;
}
.detailbottombar > div {
  float: left;
  flex: 1;
}
.right {
  width: 188px;
  display: flex;
}
.right > span {
  display: flex;
  flex: 1;
  height: 49px;
  flex-flow: column nowrap;
  justify-content: center;
  align-items: center;
}
.right > span .icon {
  height: 22px;
  width: 22px;
  margin: 2px 0px;
  background: url("~assets/img/detail/detail_bottom.png") 0 41%/100% no-repeat;
}
.right > span:nth-child(2) .icon {
  background: url("~assets/img/detail/detail_bottom.png") 0 76%/100% no-repeat;
}
.right > span:nth-child(3) .icon {
  background: url("~assets/img/detail/detail_bottom.png") 0 0/100% no-repeat;
}
.center {
  position: relative;
  height: 49px;
  width: 30px;
}
.center img {
  margin: 2px 0px;
  width: 22px;
  height: 22px;
  vertical-align: middle;
}
.left {
  display: flex;
  height: 100%;
}
.left > div {
  flex: 1;
  height: 30px;
  width: 90px;
  line-height: 30px;
  margin: 9px 3px;
  border-radius: 24px;
  color: white;
  font-family: STHeiti;
  font-weight: 700;
}
.left .shopcar {
  background: linear-gradient(to right, red, rgb(255, 86, 86));
}
.left .buy {
  background: linear-gradient(to right, rgb(255, 190, 13), rgb(255, 199, 13));
}
.shopcar:active,
.buy:active {
  opacity: 0.5;
}
.little {
  position: absolute;
  height: 15px;
  width: 15px;
  top: 0;
  right: 0px;
  background-color: red;
  color: white;
  border-radius: 50%;
  font-size: 12px;
}
</style>
